package cn.tedu.finance.controller;

import cn.tedu.base.response.JsonResult;
import cn.tedu.finance.pojo.dto.PaymentQuery;
import cn.tedu.finance.pojo.dto.PaymentSaveParam;
import cn.tedu.finance.pojo.vo.PaymentVO;
import cn.tedu.finance.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/finance/payment")
public class PaymentController {
    @Autowired
    PaymentService paymentService;

    @GetMapping("select")
    public JsonResult selectPayment(PaymentQuery paymentQuery){
        log.info("查询付款申请信息，参数：{}",paymentQuery);
        List<PaymentVO> list = paymentService.selectPayment(paymentQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult savePayment(PaymentSaveParam paymentSaveParam){
        log.info("保存付款申请信息，参数：{}",paymentSaveParam);
        paymentService.savePayment(paymentSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("cancel/{id}")
    public JsonResult cancelPayment(@PathVariable Long id){
        log.info("取消付款申请，参数：{}",id);
        paymentService.cancelPayment(id);
        return JsonResult.ok();
    }







}
